package cn.appinfo.controller;

import cn.appinfo.pojo.DevUser;
import cn.appinfo.service.DevUserService;
import cn.appinfo.tools.Constants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/dev")
public class DevUserController {

    @Resource
    private DevUserService devUserService;

    @RequestMapping("/login")
    public String login(){
        return "devlogin";
    }

    @RequestMapping("/dologin")
    public String dologin(String devCode, String devPassword, HttpSession session){
        DevUser devUser=devUserService.login(devCode,devPassword);
        if(devUser!=null){
            session.setAttribute(Constants.DEV_USER_SESSION,devUser);
            return "developer/main";
        }
        return "devlogin";
    }
}
